<template>
	<!-- <view class="content">
		<web-view :src="src"></web-view>
		<view class="btn" @click="back()">返回</view>
	</view> -->
	<!-- <view> -->
	<view class="content" :style="{ paddingTop: totalheight }">
		<view class="head" :style="{ paddingTop: navBarHeight }">
			<view class="head-np">
				<image @click="back()" class="back" src="@/static/img/chat-09.png" mode="widthFix"></image>
				<!-- <uni-icons class="back" type="left" size="30" color="white"></uni-icons> -->
				<view class="title">C2C</view>
			</view>
		</view>
		<view class="bg_color" :style="{ top: totalheight }"></view>
		<swiper class="swiper" circular autoplay>
			<swiper-item v-for="(item,i) in imgList" :key="i">
				<image src="../../static/img/m_banner1.jpg" mode="widthFix"></image>
			</swiper-item>
		</swiper>
		<view class="type">
			<view class="type-box" v-for="item in typeList" @click="navigateTo(item.path)">
				<image :src="item.img" mode="widthFix"></image>
				<view>{{item.title}}</view>
			</view>
		</view>
		<view class="data_title"><text></text>CC数据概览</view>
		<view class="data_cc">
			<view class="data_cc_item c_img1">
				<view>{{cInfo.countOrder}}</view>
				<view>当前求购总数</view>
			</view>
			<view class="data_cc_item c_img2">
				<view>{{cInfo.yesterdayTotal}}</view>
				<view>昨日成交数</view>
			</view>
		</view>
		<view class="data_cc">
			<view class="data_cc_item c_img3">
				<view>{{cInfo.countIntervalPrice}}</view>
				<view>当前区间价</view>
			</view>
			<view class="data_cc_item c_img4">
				<view>{{cInfo.tradeFeeDestroyPool}}</view>
				<view>交易手续费</view>
			</view>
		</view>
		<view class="data_title">
			<text class="col_2"></text>最新交易
			<image src="@/static/img/new-ic.png" mode="widthFix"></image>
		</view>
		<view class="trade-box">
			<view class="trade-title">
				<view class="trade-imt">ID</view>
				<view class="trade-imt">类型</view>
				<view class="trade-imt">数量</view>
				<view class="trade-imt">价格</view>
				<view class="trade-imt">时间</view>
			</view>
			<view class="trade-list">
				<view class="trade-zmbox">
					<view class="trade-zm">
						<view class="trade-ls-im" v-for="item in tradeList">
							<!--  -->
							<view class="im-val">{{ encrypt(item.id) }}</view>
							<view class="im-val"> {{ item.tradeType == 1 ? '买入' : '售出' }} </view>
							<view class="im-val">{{ item.tradeNum }}</view>
							<view class="im-val">{{ item.tradePrice }}</view>
							<view class="im-val"><uni-dateformat :date="item.created"
									format="MM-dd hh:mm"></uni-dateformat></view>
						</view>
					</view>
					<view class="trade-zm">
						<view class="trade-ls-im" v-for="item in tradeList">
							<view class="im-val">{{ encrypt(item.id) }}</view>
							<view class="im-val"> {{ item.tradeType == 1 ? '买入' : '售出' }} </view>
							<view class="im-val">{{ item.tradeNum }}</view>
							<view class="im-val">{{ item.tradePrice }}</view>
							<view class="im-val"><uni-dateformat :date="item.created"
									format="MM-dd hh:mm"></uni-dateformat></view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		lastTrade,
		getTradeOrderConfigInfo
	} from '@/api/api.js'
	import navBarMixin from '@/mixin/navBarMixin.js'
	export default {
		mixins: [navBarMixin],
		data() {
			return {
				imgList: [0],
				typeList: [{
						img: '../../static/img/set_t1.png',
						title: '委托买入',
						text: '查看买入订单详情',
						path: '/pages/me/comm?type=1'
					},
					{
						img: '../../static/img/set_t2.png',
						title: '委托出售',
						text: '查看出售订单详情',
						path: '/pages/me/comm?type=2'
					},
					// {
					// 	img: '../../static/img/set_t3.png',
					// 	title: '我的钱包',
					// 	text: '闪电充值，更方便',
					// 	path: '/pages/money/wallet'
					// },
					{
						img: '../../static/img/set_t5.png',
						title: '委托订单',
						text: '查看委托订单详情',
						path: '/pages/me/commOrder'
					}
				],
				tradeList: [],
				copyList: [],
				tradeTop: 0,
				scrollTop: 0, // 列表的滚动位置
				timer: null, // 定时器  
				islogin: false,
				cInfo: '',
			}
		},
		onLoad() {
			// if (uni.getStorageSync('islogin')) {
			// 	this.islogin = uni.getStorageSync('islogin')
			// }
			this.c2c()
		},
		onShow() {
			this.getTradeList()
		},
		mounted() {},
		methods: {
			c2c() {
				getTradeOrderConfigInfo().then(res => {
					console.log(res);
					this.cInfo = res.data
				})
			},
			back() {
				uni.navigateBack()
			},
			async getTradeList() {
				const res = await lastTrade({
					pageNum: 1,
					pageSize: 20
				})
				if (res.code == 0) {
					this.tradeList = res.data.records
				}
			},
			encrypt(id) {
				// return id.

				// console.log(id.toString().split(''))
				const idArr = id.toString().split('')
				// console.log(id)
				return idArr[0] + '**' + idArr[idArr.length - 1]
			},

			navigateTo(e) {
				uni.navigateTo({
					url: e
				})
			}
		},
	}
</script>

<style scoped lang="less">
	.content {
		overflow: hidden;
		background-color: white;
		padding-bottom: 50rpx;
		position: relative;
	}

	.head {
		position: fixed;
		top: 0;
		z-index: 1;
		width: 100%;
		background: #fff;
		background: linear-gradient(to bottom, #B8D7FF 1%, #D2E6FF 99%);

		.head-np {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 100%;
			height: 96rpx;
			padding: 0 30rpx;
			// box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(50, 50, 50, 0.1);
			box-sizing: border-box;
			position: relative;

			.title {
				font-size: 36rpx;
				font-weight: bold;
			}

			.back {
				width: 20rpx;
				position: absolute;
				left: 30rpx;
			}

		}
	}

	.bg_color {
		width: 100vw;
		height: 600rpx;
		background: linear-gradient(to bottom, #D2E6FF 1%, #ffffff 90%);
		position: absolute;
		left: 0;
	}

	.swiper {
		height: 300rpx;
		margin: 30rpx;
		// background-color: pink;
	}

	.swiper image {
		width: 690rpx;
		border-radius: 16rpx;
	}

	.info {
		margin: 30rpx 0;
		background-color: white;
		border-radius: 10rpx;
		padding: 20rpx 0 1rpx;
	}

	.type {
		margin: 40rpx 60rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: relative;

		.type-box {
			text-align: center;

			image {
				width: 104rpx;
				display: block;
				margin: 0 auto 20rpx;
			}

			view {
				font-size: 28rpx
			}
		}
	}

	.data_title {
		display: flex;
		align-items: center;
		font-weight: 500;
		font-size: 32rpx;
		color: #333333;
		// line-height: 48rpx;
		margin: 52rpx 30rpx 30rpx;
		position: relative;

		text {
			width: 5rpx;
			height: 20rpx;
			background: #6EA4F2;
			border-radius: 3rpx;
			margin-right: 14rpx;
		}

		.col_2 {
			background: #9B6AF3;
		}

		image {
			width: 40rpx;
			position: relative;
			top: -14rpx;
		}
	}

	.data_cc {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 0 30rpx 24rpx;

		.data_cc_item {
			width: 332rpx;
			height: 152rpx;

			view {
				margin-left: 30rpx;

				&:nth-of-type(1) {
					font-weight: 500;
					font-size: 28rpx;
					margin-top: 30rpx;
					margin-bottom: 8rpx;
					line-height: 42rpx;
				}

				&:nth-of-type(2) {
					font-size: 24rpx;
					line-height: 42rpx;
					color: #666666;
				}
			}
		}

		.c_img1 {
			background: url('@/static/img/c_img1.png') no-repeat;
			background-size: cover;
		}

		.c_img2 {
			background: url('@/static/img/c_img2.png') no-repeat;
			background-size: cover;
		}

		.c_img3 {
			background: url('@/static/img/c_img3.png') no-repeat;
			background-size: cover;
		}

		.c_img4 {
			background: url('@/static/img/c_img4.png') no-repeat;
			background-size: cover;
		}
	}

	.trade-box {
		margin: 30rpx;
		height: 670rpx;
		padding: 30rpx;
		// background: linear-gradient(180deg, #F8F2FD 1%, #FFFFFF 100%);
		// background: linear-gradient( to bottom, #EAF3FF 1%, #FFFFFF 50%);
		background: url('@/static/img/c_bg1.png') no-repeat;
		background-size: contain;

		.trade-title {
			display: flex;
			padding-bottom: 20rpx;
			border-bottom: 2rpx solid #EEE;

			.trade-imt {
				flex: 1;
				font-size: 28rpx;
				color: #333;
				text-align: center;

				&:first-child {
					text-align: left;
				}

				&:last-child {
					min-width: 172rpx;
				}
			}
		}
	}

	.trade-list {
		height: 640rpx;
		overflow: hidden;

		.trade-zm {}

		.trade-zmbox {
			animation-name: moveScreen;
			animation-duration: 40s;
			animation-iteration-count: infinite;
			animation-timing-function: linear;
		}


		.trade-ls-im {
			display: flex;
			padding: 30rpx 0;
			border-bottom: 2rpx solid #eee;

			.im-val {
				flex: 1;
				font-size: 24rpx;
				text-align: center;

				&:first-child {
					text-align: left;
				}

				&:nth-child(4) {
					color: #FF453A;
				}

				&:last-child {
					min-width: 172rpx;
				}
			}
		}
	}

	@keyframes moveScreen {
		from {
			transform: translateY(0);
		}

		to {
			transform: translateY(-50%);
		}
	}

	.trade {
		margin-top: 10rpx;
		padding: 0 30rpx;
		padding-bottom: 40rpx;

		.trade-cn {
			.t-fs {
				color: #333;
				font-weight: 500;
				font-size: 30rpx;

				text {
					position: relative;
					padding-left: 18rpx;

					&::before {
						content: '';
						position: absolute;
						left: 0;
						top: 50%;
						transform: translateY(-50%);
						width: 4rpx;
						height: 20rpx;
						background: #9B6AF3;
					}

					&::after {
						content: '';
						position: absolute;
						left: 100%;
						top: 0;
						width: 40rpx;
						height: 25rpx;
						background: url('@/static/img/new-ic.png') no-repeat;
						background-size: 100%;
					}
				}
			}

			.col_b {
				text {
					&::before {
						background: #6EA4F2;
					}

					&::after {
						background: none
					}
				}
			}


		}

		.ac-fc {
			display: flex;
			margin: 30rpx 0 40rpx;

			.fc-im {
				flex: 1;

				view:first-child {
					font-weight: 500;
					font-size: 33rpx;
					text-align: center;
				}

				view:last-child {
					font-size: 25rpx;
					color: #666666;
					text-align: center;
					margin-top: 10rpx;
				}

				&.fc-rh {
					position: relative;

					&::after {
						content: '';
						width: 2rpx;
						height: 40rpx;
						position: absolute;
						right: 0;
						top: 50%;
						transform: translateY(-50%);
						background: #DDDDDD;
					}
				}
			}

			.text_c {
				font-size: 28rpx;
				text-align: center;
			}

			&.pb-c {
				padding-bottom: 30rpx;
				border-bottom: 2rpx solid #eee;
			}
		}
	}
</style>